window.onload = function() {
	
	var Email = document.getElementById("Email");
	var Password = document.getElementById("Password");
	var LastName = document.getElementById("LastName");
	var FirstName = document.getElementById("FirstName");
	var PreferredName = document.getElementById("PreferredName");
	
	// Check for LocalStorage support.
	if (localStorage) {
		// Populate the form fields
		populateForm();

		// Get the form
		var form = document.getElementById("NewStudentForm");
}
}

function saveData() {
	// Store the values.
	localStorage.setItem("Email", Email.value);
	localStorage.setItem("Password", Password.value);
	localStorage.setItem("LastName", LastName.value);
	localStorage.setItem("FirstName", FirstName.value);
	localStorage.setItem("PreferredName", PreferredName.value);

}

// Attempt to populate the form using data stored in LocalStorage.
function populateForm() {

	// Retrieve the saved data and update the values of the form fields.
		if (localStorage.getItem("Email") != null){
		Email.value = localStorage.getItem("Email");
			}
if (localStorage.getItem("LastName") != null){
		LastName.value = localStorage.getItem("LastName");
			}
			if (localStorage.getItem("FirstName") != null){
		FirstName.value = localStorage.getItem("FirstName");
			}
			if (localStorage.getItem("PreferredName") != null){
		PreferredName.value = localStorage.getItem("PreferredName");
			}

}